﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Box2D.XNA;
using Spinning.Spinning.Unitity;

namespace Spinning.Spinning.Entity
{
    class Actor : PhysicSprite
    {

        public enum SpinningMoveType
        {
            Forward, StayMeddle, GoBack
        }

        public SpinningMoveType CurrentSpinningType
        {
            get;
            set;
        }

        public Actor()
            : base()
        {
            CurrentSpinningType = SpinningMoveType.StayMeddle;
        }

        public int Style
        {
            get;
            set;
        }

        public Vector3 Accelerometer
        {
            get;
            set;
        }

        protected override void UpdateSelf(GameTime gameTime)
        {
            base.UpdateSelf(gameTime);
            if (body.GetLinearVelocity().Y > 16)
            {
                SetChangeFrameAnimation(new int[] { 4 + Style * 6, 5 + Style * 6 });
                CurrentSpinningType = SpinningMoveType.Forward;
            }
            else if (body.GetLinearVelocity().Y > -16)
            {
                SetChangeFrameAnimation(new int[] { 2 + Style * 6, 3 + Style * 6 });
                CurrentSpinningType = SpinningMoveType.GoBack;
            }
            else
            {
                SetChangeFrameAnimation(new int[] { 0 + Style * 6, 1 + Style * 6 });
                CurrentSpinningType = SpinningMoveType.StayMeddle;
            }
        }
    }
}
